home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / bash_114.zip / bash-1.14.2 / variables.h < prev    next >
C/C++ Source or Header  |  1994-07-14  |  5KB  |  109 lines

  1. /* variables.h -- data structures for shell variables. */
  2.  
  3. #if !defined (_VARIABLES_H_)
  4. #define _VARIABLES_H_
  5.  
  6. #include "stdc.h"
  7.  
  8. /* Shell variables and functions are stored in hash tables. */
  9. #include "hash.h"
  10.  
  11. /* What a shell variable looks like. */
  12.  
  13. typedef struct variable *DYNAMIC_FUNC ();
  14.  
  15. typedef struct variable {
  16.   char *name;            /* Symbol that the user types. */
  17.   char *value;            /* Value that is returned. */
  18.   DYNAMIC_FUNC *dynamic_value;    /* Function called to return a `dynamic'
  19.                    value for a variable, like $SECONDS
  20.                    or $RANDOM. */
  21.   DYNAMIC_FUNC *assign_func;     /* Function called when this `special
  22.                    variable' is assigned a value in
  23.                    bind_variable. */
  24.   int attributes;        /* export, readonly, array, invisible... */
  25.   int context;            /* Which context this variable belongs to. */
  26.   struct variable *prev_context; /* Value from previous context or NULL. */
  27. } SHELL_VAR;
  28.  
  29. /* The various attributes that a given variable can have.
  30.    We only reserve one byte of the INT. */
  31. #define att_exported  0x01    /* %00000001 (export to environment) */
  32. #define att_readonly  0x02    /* %00000010 (cannot change)         */
  33. #define att_invisible 0x04    /* %00000100 (cannot see)         */
  34. #define att_array     0x08    /* %00001000 (value is an array)     */
  35. #define att_nounset   0x10    /* %00010000 (cannot unset)         */
  36. #define att_function  0x20    /* %00100000 (value is a function)   */
  37. #define att_integer   0x40    /* %01000000 (internal rep. is int)  */
  38. #define att_imported  0x80    /* %10000000 (came from environment) */
  39.  
  40. #define exported_p(var)        ((((var)->attributes) & (att_exported)))
  41. #define readonly_p(var)        ((((var)->attributes) & (att_readonly)))
  42. #define invisible_p(var)    ((((var)->attributes) & (att_invisible)))
  43. #define array_p(var)        ((((var)->attributes) & (att_array)))
  44. #define function_p(var)        ((((var)->attributes) & (att_function)))
  45. #define integer_p(var)        ((((var)->attributes) & (att_integer)))
  46. #define imported_p(var)         ((((var)->attributes) & (att_imported)))
  47.  
  48. #define value_cell(var) ((var)->value)
  49. #define function_cell(var) (COMMAND *)((var)->value)
  50.  
  51. /* Stuff for hacking variables. */
  52. extern int variable_context;
  53. extern HASH_TABLE *shell_variables, *shell_functions;
  54. extern char *dollar_vars[];
  55. extern char **export_env;
  56. extern char **non_unsettable_vars;
  57.  
  58. extern void initialize_shell_variables __P((char **));
  59.  
  60. extern SHELL_VAR *find_function __P((char *));
  61. extern SHELL_VAR *find_variable __P((char *));
  62. extern SHELL_VAR *find_variable_internal __P((char *, int));
  63. extern SHELL_VAR *find_tempenv_variable __P((char *));
  64. extern SHELL_VAR *copy_variable __P((SHELL_VAR *));
  65. extern SHELL_VAR *set_if_not __P((char *, char *));
  66. extern SHELL_VAR *make_local_variable __P((char *));
  67. extern SHELL_VAR *bind_variable __P((char *, char *));
  68. extern SHELL_VAR *bind_function __P((char *, COMMAND *));
  69. extern SHELL_VAR **map_over __P((Function *, HASH_TABLE *));
  70. extern SHELL_VAR **all_shell_variables __P((void));
  71. extern SHELL_VAR **all_shell_functions __P((void));
  72. extern SHELL_VAR **all_visible_variables __P((void));
  73. extern SHELL_VAR **all_visible_functions __P((void));
  74.  
  75. extern char **make_var_array __P((HASH_TABLE *));
  76. extern char **add_or_supercede __P((char *, char **));
  77.  
  78. extern char *get_string_value __P((char *));
  79.  
  80. extern int assignment __P((char *));
  81. extern int variable_in_context __P((SHELL_VAR *));
  82. extern int assign_in_env __P((char *));
  83. extern int unbind_variable __P((char *));
  84. extern int makunbound __P((char *, HASH_TABLE *));
  85. extern int kill_local_variable __P((char *));
  86. extern void delete_all_variables __P((HASH_TABLE *));
  87.  
  88. extern void adjust_shell_level __P((int));
  89. extern void non_unsettable __P((char *));
  90. extern void dispose_variable __P((SHELL_VAR *));
  91. extern void dispose_function_env __P((void));
  92. extern void dispose_builtin_env __P((void));
  93. extern void dispose_used_env_vars __P((void));
  94. extern void kill_all_local_variables __P((void));
  95. extern void set_var_read_only __P((char *));
  96. extern void set_func_read_only __P((char *));
  97. extern void set_var_auto_export __P((char *));
  98. extern void set_func_auto_export __P((char *));
  99. extern void sort_char_array __P((char **));
  100. extern void sort_variables __P((SHELL_VAR **));
  101. extern void maybe_make_export_env __P((void));
  102. extern void put_command_name_into_env __P((char *));
  103. extern void print_var_list __P((SHELL_VAR **));
  104. extern void print_assignment __P((SHELL_VAR *));
  105. extern void print_var_value __P((SHELL_VAR *));
  106. extern void print_var_function __P((SHELL_VAR *));
  107.  
  108. #endif /* !_VARIABLES_H_ */
  109.